#!/bin/bash

HERE=$(cd "$(dirname "$0")"; pwd)

RES="${HERE}/../Resources"

# Set to the preferred Java VM
JAVA=$(which java)

LIBRARY_PATH="${RES}/lib"

if [ -f "$JAVA" ] && [ -x "$JAVA" ] ; then
exec "${JAVA}" -Djava.library.path="${LIBRARY_PATH}" -Xdock:icon="${RES}/IrScrutinizer.icns" -Xdock:name="IrScrutinizer" -jar "${RES}/IrScrutinizer-jar-with-dependencies.jar" -p "${HOME}/.IrScrutinizer.properties.xml"
else
  # display error message with applescript
  osascript -e "tell application \"System Events\" to display dialog \"Error launching IrScrutinizer.\n\nYou need to have Java installed.\nVisit http://java.com for more information...\" with title \"IrScrutinizer\" buttons {\" OK \"} default button 1"
  # and open java.com
  open http://java.com
  # exit with error
  exit 1
fi
